//
//  QSBaseViewController.swift
//  TestSwift
//
//  Created by Song on 2018/4/29.
//  Copyright © 2018 Song. All rights reserved.
//

import UIKit
import ETNavBarTransparent

class QSBaseViewController: UIViewController {
    // 导航栏底部线的颜色
    private let shadowImageColor = UIColor.white
    private let navBarBackgroundColor = UIColor.white
    
    // MARK: - Life Cycle
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        
        // 默认不使用大标题
        self.qs_useNavLargeTitle(true)
        // 设置导航栏的title的字体和颜色
        self.qs_setNavTitle()
        // 设置导航栏大标题的字体和颜色
        self.qs_setNavLargeTitle(font: nil)
        // 默认不需要导航栏的黑线
        self.qs_setNavBarShadowImage(color: self.shadowImageColor)
        // 默认不穿透导航栏
        self.qs_setExtendNavLayout(isExtend: false)
        // 默认不隐藏导航栏
        self.qs_hideNavBar(false, animated: true)
        // 设置导航栏的背景颜色
        self.qs_setNavBarBackgroundColor(self.navBarBackgroundColor)
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        
        if let nav = self.navigationController {
            nav.interactivePopGestureRecognizer?.isEnabled = nav.childViewControllers.count > 1
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.view.backgroundColor = UIColor.white;
        // 设置返回按钮
        if let nav = self.navigationController {
            if nav.childViewControllers.count > 1 {
                // 设置返回按钮
                self.qs_setReturnBtn(img: "", title: "sdfsdf", titleColor: kOrangeColor, titleFont: UIFont.qs_systemFontSize(15.0))
            }
        }
        
        // 添加子控件
        self.qs_setupSubViews()
    }
    
    // MARK: - Private Methods
    /**
     *  设置子控件
     */
    func qs_setupSubViews() {
        
    }
}
